package com.lx.oms.controller.controller;

import java.math.BigInteger;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lx.oms.common.annotation.SysLog;
import com.lx.oms.common.controller.AbstractController;
import com.lx.oms.common.entity.Page;
import com.lx.oms.common.entity.R;
import com.lx.oms.controller.entity.UserEnterpriseEntity;
import com.lx.oms.controller.service.UserEnterpriseService;

/**
 * 企业
 *
 * @author houzhong
 * @date 2018年7月10日 下午3:11:42
 */
@RestController
@RequestMapping("/sys/userenterprise")
public class UserEnterpriseController extends AbstractController {
	
	@Autowired
	private UserEnterpriseService userEnterpriseService;
	
	/**
	 * 列表
	 * @param params
	 * @return
	 */
	@RequestMapping("/list")
	public Page<UserEnterpriseEntity> list(@RequestBody Map<String, Object> params) {
		return userEnterpriseService.listUserEnterprise(params);
	}
		
	/**
	 * 新增
	 * @param tUserEnterprise
	 * @return
	 */
	@SysLog("新增企业")
	@RequestMapping("/save")
	public R save(@RequestBody UserEnterpriseEntity userEnterprise) {
		return userEnterpriseService.saveUserEnterprise(userEnterprise);
	}
	
	/**
	 * 根据id查询详情
	 * @param id
	 * @return
	 */
	@RequestMapping("/info")
	public R getById(@RequestBody String id) {
		BigInteger bId = new BigInteger(id);
		return userEnterpriseService.getUserEnterpriseById(bId);
	}
	
	/**
	 * 修改
	 * @param tUserEnterprise
	 * @return
	 */
	@SysLog("修改企业")
	@RequestMapping("/update")
	public R update(@RequestBody UserEnterpriseEntity userEnterprise) {
		return userEnterpriseService.updateUserEnterprise(userEnterprise);
	}
	
	/**
	 * 删除
	 * @param id
	 * @return
	 */
	@SysLog("删除企业")
	@RequestMapping("/remove")
	public R batchRemove(@RequestBody String[] id) {
		return userEnterpriseService.batchRemove(id);
	}
	
}
